#!/usr/bin/python
# -*- coding: utf-8 -*-
import linecache

x = linecache.getlines('vnu.conf', 4)
server_names = []
for i in range(len(x)):
    line = x[i]
    if '443' in line:
        server_names.append(x[i+1])

temp_list = []
results = []
for server_name in server_names:
    temp_list = server_name.strip().split(' ')
    for i in temp_list:
        print(i)
        if i != 'server_name':
            results.append(i)

print(results)


def get_servername():
    path='/etc/nginx/conf.d/'
    file_list = []
    results = []
    for files in os.listdir(path):
        if os.path.isfile(path + files):
            file_list.append(files)
    for file in file_list:
        x = linecache.getlines(path + file)
        server_names = []
        for i in range(len(x)):
            line = x[i]
            if '443' in line:
                server_names.append(x[i+1])

        temp_list = []
        for server_name in server_names:
            temp_list = server_name.strip().split(' ')
            for i in temp_list:
                if i != 'server_name':
                    results.append(i)